<extend name="Public/base"/>

<block name="body">
    <div class="cf">
        <h2>{$meta_title}</h2>
    </div>

    <form id="form" width="79%" action="{:U('update')}" method="post" class="form-horizontal fl">
        <div class="cf">
            <label>填写应用的场景</label>
            <input type="text" name="scene" placeholder="应用场景" value="" />
            <label>填写开始时间(选填)</label>
            <input type="text" name="startTime" placeholder="开始时间，不填马上有效" value="" />
            <label>选择回复的类型</label>
            <select name="reply_type" id="">
                <option value="text">文本</option>
                <option value="news">新闻</option>
                <option value="document">文章</option>
                <option value="category">分类</option>
            </select>
            <label>回复内容</label>
            <textarea name="reply_id" id="reply_id" cols="30" rows="10"></textarea>
            <label>填写过期时间(选填)</label>
            <input type="text" name="deadLine" placeholder="过期时间，不填不过期" value="" />
            <label>过期后回复内容(选填)</label>
            <textarea name="deadText" id="deadText" cols="30" rows="10"></textarea>
        </div>
        <div class="form-item cf">
            <button class="btn submit-btn ajax-post hidden" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <a class="btn btn-return" href="">返 回</a>
            <input type="hidden" name="qrid" value=""/>
        </div>
    </form>

    <div class="cf">
        <button class="btn btn-default" id="getQrCode" >生成二维码</button>
        <div id="qrImage"></div>
    </div>

</block>

<!-- 加载底部JS -->
<block name="script">
    <script type="text/javascript">
        $("button#getQrCode").click(function(){
            var scene = $("input[name='scene']").val();
            if(''==scene){
                alert('应用场景不能为空');
            }else{
                $.post(
                        "{:U('getTicket')}",
                        {"scene":scene},
                        function ($data) {
                            $str = '<img src="'+$data.image+'" alt="二维码"/>';
                            $('#qrImage').html($str);
                            $("input[name='qrid']").val($data.id);
                        }
                );
            }
        });
    </script>
</block>
